<template>
  <div>
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-row>
        <el-col :span="22">
          <el-form-item label="通行策略">
            <el-input
              v-model="form.name"
              placeholder="请输入通行策略"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="search">查询</el-button>
            <el-button @click="reset">重置</el-button>
          </el-form-item>
        </el-col>
        <el-col :span="2">
          <el-button type="primary" @click="handleAdd">添加</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="strategyName" label="策略名称"> </el-table-column>
      <el-table-column prop="createTime" label="创建时间"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑
          </el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <access-dialog ref="accessDialogRef"></access-dialog>
  </div>
</template>

<script>
// import { getpassStrategyApi } from "@/api/intelligent";
import accessDialog from "../components/accessDialog.vue";

export default {
  name: "MvCloudgateTerminalAccessStrategy",
  components: {
    accessDialog,
  },
  data() {
    return {
      form: {
        name: "",
      },
      tableData: [
        // {
        //   date: "2016-05-02",
        //   name: "王小虎",
        // },
        // {
        //   date: "2016-05-04",
        //   name: "王小虎",
        // },
        // {
        //   date: "2016-05-01",
        //   name: "王小虎",
        // },
        // {
        //   date: "2016-05-03",
        //   name: "王小虎",
        // },
      ],
    };
  },

  mounted() {
    this.getpassStrategy();
  },

  methods: {
    search() {
      this.getpassStrategy();
    },
    reset() {},
    handleEdit(index, row) {
      // console.log(index, row);
      this.$refs.accessDialogRef.edit(row);
    },
    handleDelete(index, row) {
      // console.log(index, row);
      console.log(JSON.parse(row.normalStrategy));
    },
    handleAdd() {
      this.$refs.accessDialogRef.add();
    },
    getpassStrategy() {
      getpassStrategyApi(this.form).then((res) => {
        // console.log(res);
        this.tableData = res;
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
